package marchsoft.modules.system.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import marchsoft.base.BasicMapper;
import marchsoft.modules.system.entity.DictValue;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@CacheConfig(cacheNames = "dict")
public interface DictValueMapper extends BasicMapper<DictValue> {

    /**
     * 根据字典主表id查询字典子表
     *
     * @param typeId 字典主表id
     * @return 字典子表
     */
    @Select("SELECT a.id, a.dict_type_id, a.dict_name, a.dict_code,a.sort " +
            " FROM sys_dict_value a, sys_dict_type b WHERE a.dict_type_id = b.id " +
            " AND a.dict_type_id" +
            " = #{typeId} order by a.sort")
    @Cacheable(key = "'typeId:' + #p0")
    IPage<Map<String,Object>> selectDictValuePage(Page page, Long typeId);



}
